package com.dongchao.authserver.security.service.impl;

import com.dongchao.authserver.security.dao.UserDao;
import com.dongchao.authserver.security.entity.SysUser;
import com.dongchao.authserver.security.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author Mr.dongchao
 * @date 2018-08-28
 **/
@Component
public class UserServiceImpl  implements UserService {
    @Autowired
    private RedisConnectionFactory redisConnectionFactory;
    @Autowired
    private UserDao userDao ;
    @Override
    public SysUser findUserByUsername(String username) {
        SysUser currUser = userDao.findUserByName(username);
        if (null != currUser){
            List<String> roles = userDao.queryAllRoleByUsername(currUser.getUserId());
            currUser.setRoleList(roles);
        }
        return currUser;
    }

    @Override
    public SysUser findUserByMobile(String mobile) {
        return null;
    }

    @Override
    public SysUser findUserByOpenId(String openId) {
        return null;
    }
}
